package top.mccat.filesystem.factory;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * @author raven
 */
public class CookieFactory {
    /**
     * 生成Cookie的工厂方法
     * @param name cookie名
     * @param value cookie参数
     * @param maxAge 最大存活时间
     * @return Cookie，如果参数均为空则返回空参数
     */
    public static Cookie setCookie(String name, String value,Integer maxAge){
        if(name == null || value == null || maxAge == null || "".equals(name) || "".equals(value)){
            return null;
        }
        Cookie cookie = new Cookie(name, value);
        cookie.setPath("/");
        cookie.setMaxAge(maxAge);
        return cookie;
    }
}